home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume17 / parseargs / patch02 < prev    next >
Encoding:
Internet Message Format  |  1991-03-27  |  40.3 KB

  1. From: brad@hcx1.ssd.csd.harris.com (Brad Appleton)
  2. Newsgroups: comp.sources.misc
  3. Subject: v17i073:  parseargs - functions to parse command line arguments, Patch02
  4. Message-ID: <1991Mar27.184544.14898@sparky.IMD.Sterling.COM>
  5. Date: 27 Mar 91 18:45:44 GMT
  6. Approved: kent@sparky.imd.sterling.com
  7. X-Checksum-Snefru: 9485c35d a31c80cc 5e020724 384ed733
  8.  
  9. Submitted-by: Brad Appleton <brad@hcx1.ssd.csd.harris.com>
  10. Posting-number: Volume 17, Issue 73
  11. Archive-name: parseargs/patch02
  12. Patch-To: parseargs: Volume 17, Issue 00-12
  13.  
  14. This is the second patch for parseargs. It fixes most of the documentation
  15. errors (It is NOT a bug-fix).
  16.  
  17. ______________________ "And miles to go before I sleep." ______________________
  18.  Brad Appleton                         Harris Corp., Computer Systems Division
  19.    Software Engineer                   2101 West Cypress Creek Road,  M/S 161 
  20.      brad@ssd.csd.harris.com           Fort Lauderdale, FL  33309-1892  USA
  21.        ...!uunet!hcx1!brad                 Phone: (305) 973-5360
  22. ~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~
  23. -----------------
  24. #! /bin/sh
  25. # This is a shell archive.  Remove anything before this line, then unpack
  26. # it by saving it into a file and typing "sh file".  To overwrite existing
  27. # files, type "sh file -c".  You can also feed this as standard input via
  28. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  29. # will see the following message at the end:
  30. #        "End of shell archive."
  31. # Contents:  PATCH
  32. # Wrapped by brad@hcx2 on Tue Mar 26 11:42:19 1991
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'PATCH' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'PATCH'\"
  36. else
  37. echo shar: Extracting \"'PATCH'\" \(38200 characters\)
  38. sed "s/^X//" >'PATCH' <<'END_OF_FILE'
  39. X*** argtype.c.OLD    Tue Mar 26 11:31:00 1991
  40. X--- argtype.c    Tue Mar 26 10:19:41 1991
  41. X***************
  42. X*** 79,85 ****
  43. X  ** ^DESCRIPTION:
  44. X  **    Each of these converts a parameter value to the internal form, includ-
  45. X  **    ing validity checking.  Their parameters and return values all behave
  46. X! **    similarly. One of these routines are called when an argunent of that
  47. X  **    particular type is matched by one of the argument parsing function in
  48. X  **    parseargs(3). When such an argument is matched, its argument transla-
  49. X  **    tion routines is invoked and is passed (1) the address of the argument
  50. X--- 79,85 ----
  51. X  ** ^DESCRIPTION:
  52. X  **    Each of these converts a parameter value to the internal form, includ-
  53. X  **    ing validity checking.  Their parameters and return values all behave
  54. X! **    similarly. One of these routines is called when an argument of that
  55. X  **    particular type is matched by one of the argument parsing function in
  56. X  **    parseargs(3). When such an argument is matched, its argument transla-
  57. X  **    tion routines is invoked and is passed (1) the address of the argument
  58. X***************
  59. X*** 151,157 ****
  60. X  **    usage to be printed.
  61. X  **
  62. X  **    ArgDummy is used to force an item to show up in usage-messages but
  63. X! **    the item itself is never matched against any argumenmts from the
  64. X  **    command-line.
  65. X  **
  66. X  **    ArgEnd is used by amiga_args.c and vms_args.c to indicate an argument
  67. X--- 151,157 ----
  68. X  **    usage to be printed.
  69. X  **
  70. X  **    ArgDummy is used to force an item to show up in usage-messages but
  71. X! **    the item itself is never matched against any arguments from the
  72. X  **    command-line.
  73. X  **
  74. X  **    ArgEnd is used by amiga_args.c and vms_args.c to indicate an argument
  75. X*** doc/argdesc.inc.OLD    Tue Mar 26 11:31:16 1991
  76. X--- doc/argdesc.inc    Tue Mar 26 11:01:10 1991
  77. X***************
  78. X*** 22,28 ****
  79. X  .\"---------------------------------------------
  80. X  .IP "\fIargTypePtr_t  ad_type;\fP"
  81. X  This field is a pointer to a type conversion function (such as the
  82. X! ones provided in \fIargtype\fP(3). The type conversion function is
  83. X  responsible for verifying the validity of the argument, allocating any
  84. X  necessary storage for its internal representation, and converting
  85. X  the command-line argument into its required internal form. The type
  86. X--- 22,28 ----
  87. X  .\"---------------------------------------------
  88. X  .IP "\fIargTypePtr_t  ad_type;\fP"
  89. X  This field is a pointer to a type conversion function (such as the
  90. X! ones provided in \fIargtype\fP(3)). The type conversion function is
  91. X  responsible for verifying the validity of the argument, allocating any
  92. X  necessary storage for its internal representation, and converting
  93. X  the command-line argument into its required internal form. The type
  94. X***************
  95. X*** 41,57 ****
  96. X  pointer to a number, a boolean value, a string, a list, or anything
  97. X  else for which there exists a corresponding arg-type function to
  98. X  use in the \fIad_type\fP field. In the case of of \fIparseargs\fP(1) this
  99. X! field must be the name of the corresponding shell variable which eventually
  100. X! hold the value of the argument given on the command-line.
  101. X  .\"---------------------------------------------
  102. X  .IP "\fIconst char  *ad_prompt;\fP"
  103. X  This field contains the long-name of the argument and an optional
  104. X  description (the description must be separated from the long-name by
  105. X! at least one whitespace characters and may optionally be enclosed in
  106. X  a set of balanced delimiters (such as parentheses, curly-braces,
  107. X! square-brackets, or angle-brackets. If the long-name contains any
  108. X  uppercase characters, then the substring of long-name consisting of
  109. X! all uppercase characters is used as the argument name and the entire
  110. X! long-name is used as the name of the argument-value (if a value my be
  111. X  supplied). The long-name may be matched by supplying a unique prefix
  112. X! of either the argument name or the argument-value name.
  113. X--- 41,57 ----
  114. X  pointer to a number, a boolean value, a string, a list, or anything
  115. X  else for which there exists a corresponding arg-type function to
  116. X  use in the \fIad_type\fP field. In the case of of \fIparseargs\fP(1) this
  117. X! field must be the name of the corresponding shell variable which will
  118. X! eventually hold the value of the argument given on the command-line.
  119. X  .\"---------------------------------------------
  120. X  .IP "\fIconst char  *ad_prompt;\fP"
  121. X  This field contains the long-name of the argument and an optional
  122. X  description (the description must be separated from the long-name by
  123. X! at least one whitespace character and may optionally be enclosed in
  124. X  a set of balanced delimiters (such as parentheses, curly-braces,
  125. X! square-brackets, or angle-brackets). If the long-name contains any
  126. X  uppercase characters, then the substring of long-name consisting of
  127. X! all uppercase characters is used as the argument keyword and the entire
  128. X! long-name is used as the name of the argument (if a value my be
  129. X  supplied). The long-name may be matched by supplying a unique prefix
  130. X! of either the argument keyword or the argument name.
  131. X*** doc/argtype.man3.OLD    Tue Mar 26 11:31:22 1991
  132. X--- doc/argtype.man3    Tue Mar 26 10:24:42 1991
  133. X***************
  134. X*** 34,41 ****
  135. X  .PP
  136. X  Each of these converts a parameter value to the internal form,
  137. X  including validity checking.  Their parameters and return values
  138. X! all behave similarly. One of these routines are called when an
  139. X! argunent of that particular type is matched by one of the argument
  140. X  parsing function in \fIparseargs\fP(3). When such an argument is matched,
  141. X  its argument translation routines is invoked and is passed (1) the address of
  142. X  the argument descriptor for the matched argument, (2) the possible argument
  143. X--- 34,41 ----
  144. X  .PP
  145. X  Each of these converts a parameter value to the internal form,
  146. X  including validity checking.  Their parameters and return values
  147. X! all behave similarly. One of these routines is called when an
  148. X! argument of that particular type is matched by one of the argument
  149. X  parsing function in \fIparseargs\fP(3). When such an argument is matched,
  150. X  its argument translation routines is invoked and is passed (1) the address of
  151. X  the argument descriptor for the matched argument, (2) the possible argument
  152. X***************
  153. X*** 50,56 ****
  154. X  the matched argument has the \s-1ARGVEC\s+1 flag enabled). If the argument is
  155. X  an \s-1ARGVEC\s+1 or \s-1ARGLIST\s+1 then the routine is responsible for
  156. X  allocating any space, copying the arg-flags to the value-specific flags, and
  157. X! setting the \s-1ARGCOPYF\fP flag for the value if it needs to be allocated
  158. X  as well.
  159. X  
  160. X  .SH "RETURN VALUE"
  161. X--- 50,56 ----
  162. X  the matched argument has the \s-1ARGVEC\s+1 flag enabled). If the argument is
  163. X  an \s-1ARGVEC\s+1 or \s-1ARGLIST\s+1 then the routine is responsible for
  164. X  allocating any space, copying the arg-flags to the value-specific flags, and
  165. X! setting the \s-1ARGCOPYF\s+1 flag for the value if it needs to be allocated
  166. X  as well.
  167. X  
  168. X  .SH "RETURN VALUE"
  169. X***************
  170. X*** 65,71 ****
  171. X  The conversion was successful but only \fIN\fP characters of the value
  172. X  were used, the remaining characters may still match other arguments.
  173. X  
  174. X! .SH "PSEUDO-TYPES"
  175. X  .PP
  176. X  .I ArgUsage
  177. X  is used to specify an argument that causes the command usage to be printed.
  178. X--- 65,71 ----
  179. X  The conversion was successful but only \fIN\fP characters of the value
  180. X  were used, the remaining characters may still match other arguments.
  181. X  
  182. X! .SH "PSEUDO-TYPES: argUsage, argDummy, argEnd"
  183. X  .PP
  184. X  .I ArgUsage
  185. X  is used to specify an argument that causes the command usage to be printed.
  186. X***************
  187. X*** 72,78 ****
  188. X  
  189. X  .I ArgDummy
  190. X  is used to force an item to show up in usage-messages but
  191. X! the item itself is never matched against any argumenmts from the
  192. X  command-line.
  193. X  
  194. X  .I ArgEnd
  195. X--- 72,78 ----
  196. X  
  197. X  .I ArgDummy
  198. X  is used to force an item to show up in usage-messages but
  199. X! the item itself is never matched against any arguments from the
  200. X  command-line.
  201. X  
  202. X  .I ArgEnd
  203. X***************
  204. X*** 82,88 ****
  205. X  These three are dummy functions. The routines themselves do nothing
  206. X  of importance, we just need to have their addresses available for
  207. X  identification in the corresponding command-line styles.
  208. X! .SH "STRING-TYPES"
  209. X  .PP
  210. X  \fIArgStr\fP is one of the few argument translation routines that actually
  211. X  uses the \fIcopyf\fP flag. If \fIcopyf\fP is true then the string is
  212. X--- 82,88 ----
  213. X  These three are dummy functions. The routines themselves do nothing
  214. X  of importance, we just need to have their addresses available for
  215. X  identification in the corresponding command-line styles.
  216. X! .SH "STRING-TYPES: argStr"
  217. X  .PP
  218. X  \fIArgStr\fP is one of the few argument translation routines that actually
  219. X  uses the \fIcopyf\fP flag. If \fIcopyf\fP is true then the string is
  220. X***************
  221. X*** 94,100 ****
  222. X  
  223. X  \fIArgStr\fP ensures that the very last item in a vector of strings (the one
  224. X  accessed as \f4vec.array[ vec.count ]\fP) will always be \s-1NULL\s+1.
  225. X! .SH "CHARACTER-TYPES"
  226. X  .PP
  227. X  .I ArgChar
  228. X  assigns the given character to the value referenced by \fIarg_valp(ad)\fP
  229. X--- 94,100 ----
  230. X  
  231. X  \fIArgStr\fP ensures that the very last item in a vector of strings (the one
  232. X  accessed as \f4vec.array[ vec.count ]\fP) will always be \s-1NULL\s+1.
  233. X! .SH "CHARACTER-TYPES: argChar"
  234. X  .PP
  235. X  .I ArgChar
  236. X  assigns the given character to the value referenced by \fIarg_valp(ad)\fP
  237. X***************
  238. X*** 109,125 ****
  239. X  
  240. X  Unlike \fIargStr\fP, \fIargChar\fP will translate character escape sequences
  241. X  such as `\\n' and `\\012'.
  242. X! .SH "INTEGER-TYPES"
  243. X  .PP
  244. X  Each of these functions converts the given string to the desired
  245. X  integral type. The value may be specified as an octal number by
  246. X  specifying the first digit to be 0. Similarly, If the first two 
  247. X  characters are `0x' then the number is treated as hexadecimal.
  248. X! .SH "FLOATING-POINT-TYPES"
  249. X  .PP
  250. X  Each of these functions converts the given string to the desired
  251. X  floating-point type.
  252. X! .SH "BOOLEAN-TYPES"
  253. X  .PP
  254. X  \fIArgBool\fP and \fIargSBool\fP set a boolean value (if no value is given).
  255. X  \fIArgUBool\fP unsets a boolean value (if no value is given). \fIArgTBool\fP
  256. X--- 109,125 ----
  257. X  
  258. X  Unlike \fIargStr\fP, \fIargChar\fP will translate character escape sequences
  259. X  such as `\\n' and `\\012'.
  260. X! .SH "INTEGER-TYPES: argInt, argShort, argLong"
  261. X  .PP
  262. X  Each of these functions converts the given string to the desired
  263. X  integral type. The value may be specified as an octal number by
  264. X  specifying the first digit to be 0. Similarly, If the first two 
  265. X  characters are `0x' then the number is treated as hexadecimal.
  266. X! .SH "FLOATING-POINT-TYPES: argFloat, argDouble"
  267. X  .PP
  268. X  Each of these functions converts the given string to the desired
  269. X  floating-point type.
  270. X! .SH "BOOLEAN-TYPES: argBool, argSBool, argTBool, argUBool"
  271. X  .PP
  272. X  \fIArgBool\fP and \fIargSBool\fP set a boolean value (if no value is given).
  273. X  \fIArgUBool\fP unsets a boolean value (if no value is given). \fIArgTBool\fP
  274. X***************
  275. X*** 148,154 ****
  276. X  The corresponding boolean flag is set to \s-1FALSE\s+1.
  277. X  .IP "``1'', ``+'', ``ON'', or ``TRUE''"
  278. X  The corresponding boolean flag is set to \s-1TRUE\s+1.
  279. X! .SH LIST TYPES
  280. X  .PP
  281. X  The \fIlistStr\fP argument translation routine is only intended for use
  282. X  on behalf of arguments that have the \s-1ARGLIST\s+1 flag enabled. It will
  283. X--- 148,154 ----
  284. X  The corresponding boolean flag is set to \s-1FALSE\s+1.
  285. X  .IP "``1'', ``+'', ``ON'', or ``TRUE''"
  286. X  The corresponding boolean flag is set to \s-1TRUE\s+1.
  287. X! .SH "LIST TYPES: listStr"
  288. X  .PP
  289. X  The \fIlistStr\fP argument translation routine is only intended for use
  290. X  on behalf of arguments that have the \s-1ARGLIST\s+1 flag enabled. It will
  291. X***************
  292. X*** 168,171 ****
  293. X  type of the items in the vector.
  294. X  .SH SEE ALSO
  295. X  .IR parseargs (3),
  296. X! .IR parseargs (1),
  297. X--- 168,172 ----
  298. X  type of the items in the vector.
  299. X  .SH SEE ALSO
  300. X  .IR parseargs (3),
  301. X! .IR parseargs (3),
  302. X! .IR parsecntl (1),
  303. X*** doc/env_args.inc.OLD    Tue Mar 26 11:31:43 1991
  304. X--- doc/env_args.inc    Tue Mar 26 10:42:13 1991
  305. X***************
  306. X*** 10,16 ****
  307. X  will be parsed for any "default" arguments before the command-line is parsed.
  308. X  The command-line will over-ride any options that are specified in this
  309. X  environment variable (except that \s-1ARGLIST\s+1s and \s-1ARGVEC\s+1s set in
  310. X! ``\s-1CMD_ARGS\s+1'' will be appended from the command-line
  311. X  
  312. X  It is important to note that the contents of the ``\s-1\fICMD\fP_ARGS\s+1''
  313. X  environment variable are NOT expanded by the shell and hence any special
  314. X--- 10,17 ----
  315. X  will be parsed for any "default" arguments before the command-line is parsed.
  316. X  The command-line will over-ride any options that are specified in this
  317. X  environment variable (except that \s-1ARGLIST\s+1s and \s-1ARGVEC\s+1s set in
  318. X! ``\s-1CMD_ARGS\s+1'' will be appended from the command-line if they are
  319. X! selected).
  320. X  
  321. X  It is important to note that the contents of the ``\s-1\fICMD\fP_ARGS\s+1''
  322. X  environment variable are NOT expanded by the shell and hence any special
  323. X*** doc/env_parse.inc.OLD    Tue Mar 26 11:31:46 1991
  324. X--- doc/env_parse.inc    Tue Mar 26 10:46:48 1991
  325. X***************
  326. X*** 25,31 ****
  327. X  Ignore any unrecognized or improperly specified command-line arguments
  328. X  and continue execution of the program. Normally, if an argument is
  329. X  unmatched (or is improperly specified), a usage message is printed
  330. X! program execution is terminated.
  331. X  .\"----------------------
  332. X  .IP "\fIOptsOnly\fP"
  333. X  Under UNIX, setting this flag will disable the parsing of long-option
  334. X--- 25,31 ----
  335. X  Ignore any unrecognized or improperly specified command-line arguments
  336. X  and continue execution of the program. Normally, if an argument is
  337. X  unmatched (or is improperly specified), a usage message is printed
  338. X! and program execution is terminated.
  339. X  .\"----------------------
  340. X  .IP "\fIOptsOnly\fP"
  341. X  Under UNIX, setting this flag will disable the parsing of long-option
  342. X***************
  343. X*** 53,65 ****
  344. X  considered to consist of one option and one positional argument.
  345. X  .\"----------------------
  346. X  .IP "\fICaseIgnore\fP"
  347. X! Setting this flag cause character-case to be ignored when attempting
  348. X  to match single-character argument names (i.e. causes "-i" and "-I"
  349. X  will be considered equivalent).
  350. X  .sp 4p
  351. X  .PP
  352. X  If the environment variable ``\s-1PARSECNTL\s+1'' is empty or
  353. X! undefined, then parsing behavior set by the programmer is used.
  354. X  If the programmer has not explicitly used
  355. X  .IR parsecntl (3)
  356. X  to modify the parsing behavior, then the default behavior will be
  357. X--- 53,65 ----
  358. X  considered to consist of one option and one positional argument.
  359. X  .\"----------------------
  360. X  .IP "\fICaseIgnore\fP"
  361. X! Setting this flag causes character-case to be ignored when attempting
  362. X  to match single-character argument names (i.e. causes "-i" and "-I"
  363. X  will be considered equivalent).
  364. X  .sp 4p
  365. X  .PP
  366. X  If the environment variable ``\s-1PARSECNTL\s+1'' is empty or
  367. X! undefined, then the parsing behavior set by the programmer is used.
  368. X  If the programmer has not explicitly used
  369. X  .IR parsecntl (3)
  370. X  to modify the parsing behavior, then the default behavior will be
  371. X*** doc/lib_bugs.inc.OLD    Tue Mar 26 11:31:57 1991
  372. X--- doc/lib_bugs.inc    Tue Mar 26 11:13:04 1991
  373. X***************
  374. X*** 7,13 ****
  375. X  When a non-multivalued argument appears more than once on the command-line
  376. X  then only the last value supplied is used. A problem occurs however in the
  377. X  following scenario: suppose `\fB\-s\fP' is an option that takes an optional
  378. X! string argument (nd suppose `\fB\-x\fP' is some boolean flag). Then if the
  379. X  following command-line is issued:
  380. X  
  381. X  .RS
  382. X--- 7,13 ----
  383. X  When a non-multivalued argument appears more than once on the command-line
  384. X  then only the last value supplied is used. A problem occurs however in the
  385. X  following scenario: suppose `\fB\-s\fP' is an option that takes an optional
  386. X! string argument (and suppose `\fB\-x\fP' is some boolean flag). Then if the
  387. X  following command-line is issued:
  388. X  
  389. X  .RS
  390. X*** doc/lparseargs3.inc.OLD    Tue Mar 26 11:32:01 1991
  391. X--- doc/lparseargs3.inc    Tue Mar 26 10:54:24 1991
  392. X***************
  393. X*** 4,7 ****
  394. X  .\"----------------------------------------------------------------------------
  395. X  .PP
  396. X  Given an ArgList and an argdesc array, \fIlparseargs\fP
  397. X! will parse arguments in a file in much the same manner as \fIparseargs\fP.
  398. X--- 4,7 ----
  399. X  .\"----------------------------------------------------------------------------
  400. X  .PP
  401. X  Given an ArgList and an argdesc array, \fIlparseargs\fP
  402. X! will parse arguments in an ArgList in much the same manner as \fIparseargs\fP.
  403. X*** doc/multivals.inc.OLD    Tue Mar 26 11:32:05 1991
  404. X--- doc/multivals.inc    Tue Mar 26 11:08:39 1991
  405. X***************
  406. X*** 22,35 ****
  407. X  ArgList structure. \s-1L_NEXT\s+1 returns the address of the next item in the
  408. X  list and \s-1L_STRING\s+1 returns the string-value of the current list-item.
  409. X  \s-1L_FLAGS\s+1 return the arg-flags for a given item in the list. With
  410. X! non-multivalued, only the flags in the argument descriptor are needed; lists
  411. X! and vectors however need a set of flags for each item they contain. 
  412. X! Once an arg-list has been created, it may be deallocated using the function
  413. X  .I listFree.
  414. X  .I ListFree
  415. X! takes two parameters, the first of which is the address of the first item in
  416. X! the arg-list, and the second of which is a boolean value that is \s-1TRUE\s+1
  417. X! only if each value pointed to by each item should also be deallocated.
  418. X  .PP
  419. X  An alternative to argument-lists is argument vectors (or arg-vectors).
  420. X  Arg-vectors use the \s-1ARGVEC\s+1 flag instead of the \s-1ARGLIST\s+1 flag
  421. X--- 22,35 ----
  422. X  ArgList structure. \s-1L_NEXT\s+1 returns the address of the next item in the
  423. X  list and \s-1L_STRING\s+1 returns the string-value of the current list-item.
  424. X  \s-1L_FLAGS\s+1 return the arg-flags for a given item in the list. With
  425. X! non-multivalued arguments, only the flags in the argument descriptor are
  426. X! needed; lists and vectors however need a set of flags for each item they
  427. X! contain. Once an arg-list has been created, it may be deallocated using
  428. X! the function
  429. X  .I listFree.
  430. X  .I ListFree
  431. X! takes one parameter: first of which is the address of the first item in
  432. X! the arg-list.
  433. X  .PP
  434. X  An alternative to argument-lists is argument vectors (or arg-vectors).
  435. X  Arg-vectors use the \s-1ARGVEC\s+1 flag instead of the \s-1ARGLIST\s+1 flag
  436. X*** doc/parseargs.man1.OLD    Tue Mar 26 11:32:11 1991
  437. X--- doc/parseargs.man1    Tue Mar 26 10:34:35 1991
  438. X***************
  439. X*** 188,194 ****
  440. X  the calling program is needed in order for \fBparseargs\fP to be able to
  441. X  distinguish options to itself from options for the calling program.
  442. X  .PP
  443. X! The default behavior of parseargs is allow both single-character options and
  444. X  long-options (keywords) on the command-line. The user may specify that only
  445. X  options (long-options) are to be permitted by specifying the \fB\-o\fP
  446. X  (\fB\-l\) option on the command-line.
  447. X--- 188,194 ----
  448. X  the calling program is needed in order for \fBparseargs\fP to be able to
  449. X  distinguish options to itself from options for the calling program.
  450. X  .PP
  451. X! The default behavior of parseargs is to allow both single-character options and
  452. X  long-options (keywords) on the command-line. The user may specify that only
  453. X  options (long-options) are to be permitted by specifying the \fB\-o\fP
  454. X  (\fB\-l\) option on the command-line.
  455. X*** doc/parseargs.man3.OLD    Tue Mar 26 11:32:16 1991
  456. X--- doc/parseargs.man3    Tue Mar 26 11:12:33 1991
  457. X***************
  458. X*** 12,18 ****
  459. X  int  fparseargs(  FILE *fp,  ARGDESC *argd  )
  460. X  int  lparseargs(  ArgList *argls,  ARGDESC *argd  )
  461. X  int  sparseargs(  char *str,  ARGDESC *argd  )
  462. X! int  vparseargs(  ARGDESC *argd,  ...  )
  463. X  void  usage(  const ARGDESC *argd  )
  464. X  .fi
  465. X  .\"-----------------------------------------------------------
  466. X--- 12,18 ----
  467. X  int  fparseargs(  FILE *fp,  ARGDESC *argd  )
  468. X  int  lparseargs(  ArgList *argls,  ARGDESC *argd  )
  469. X  int  sparseargs(  char *str,  ARGDESC *argd  )
  470. X! int  vparseargs(  ARGDESC *argd, int argc,  ...  )
  471. X  void  usage(  const ARGDESC *argd  )
  472. X  .fi
  473. X  .\"-----------------------------------------------------------
  474. X***************
  475. X*** 122,134 ****
  476. X  Its main use is to find the location in which to store the converted value,
  477. X  located in argd\(->ad_valp.
  478. X  The string value to be converted is passed in
  479. X! .IR argp
  480. X  (which will be \s-1NULL\s+1 if the \s-1ARGNOVAL\s+1 flag was set for the
  481. X  corresponding entry in the arg-descriptor table).
  482. X  The
  483. X  .I copyf
  484. X  flag is TRUE if the
  485. X! .I argp
  486. X  string value must be copied when saved.
  487. X  Most non-string types are copied implicitly
  488. X  (for example, integer arguments are stored in binary form,
  489. X--- 122,134 ----
  490. X  Its main use is to find the location in which to store the converted value,
  491. X  located in argd\(->ad_valp.
  492. X  The string value to be converted is passed in
  493. X! .IR vp
  494. X  (which will be \s-1NULL\s+1 if the \s-1ARGNOVAL\s+1 flag was set for the
  495. X  corresponding entry in the arg-descriptor table).
  496. X  The
  497. X  .I copyf
  498. X  flag is TRUE if the
  499. X! .I vp
  500. X  string value must be copied when saved.
  501. X  Most non-string types are copied implicitly
  502. X  (for example, integer arguments are stored in binary form,
  503. X***************
  504. X*** 137,143 ****
  505. X  Put simply, this flag is
  506. X  TRUE
  507. X  when
  508. X! .I argp
  509. X  points to a temporary buffer area.
  510. X  .PP
  511. X  If the type function successfully converts the value,
  512. X--- 137,143 ----
  513. X  Put simply, this flag is
  514. X  TRUE
  515. X  when
  516. X! .I vp
  517. X  points to a temporary buffer area.
  518. X  .PP
  519. X  If the type function successfully converts the value,
  520. X*** doc/parseargs1.inc.OLD    Tue Mar 26 11:32:21 1991
  521. X--- doc/parseargs1.inc    Tue Mar 26 10:27:15 1991
  522. X***************
  523. X*** 14,20 ****
  524. X  extra arguments,
  525. X  and argument values that are syntactically incorrect.
  526. X  Other behavior such as prompting the user for missing arguments and
  527. X! ignoring as command-line syntax may be specified on the command-line
  528. X  through the use of various options, or through the use of the
  529. X  ``\s-1PARSECNTL\s+1'' environment variable.
  530. X  .PP
  531. X--- 14,20 ----
  532. X  extra arguments,
  533. X  and argument values that are syntactically incorrect.
  534. X  Other behavior such as prompting the user for missing arguments and
  535. X! ignoring bad command-line syntax may be specified on the command-line
  536. X  through the use of various options, or through the use of the
  537. X  ``\s-1PARSECNTL\s+1'' environment variable.
  538. X  .PP
  539. X*** doc/sh_arrays.inc.OLD    Tue Mar 26 11:32:52 1991
  540. X--- doc/sh_arrays.inc    Tue Mar 26 10:39:21 1991
  541. X***************
  542. X*** 33,39 ****
  543. X  ``\fB*\fP'', then the positional parameters of the calling program
  544. X  will be re-assigned to the contents of the argument list.
  545. X  .PP
  546. X! For the \fIawk\fP and \fIperl\fP,
  547. X  if the variable name corresponding to the \s-1ARGLIST\s+1 argument is
  548. X  ``\fBARGV\fP'', then the positional parameters of the calling program
  549. X  will be re-assigned to the contents of the argument list.
  550. X--- 33,39 ----
  551. X  ``\fB*\fP'', then the positional parameters of the calling program
  552. X  will be re-assigned to the contents of the argument list.
  553. X  .PP
  554. X! For \fIawk\fP and \fIperl\fP,
  555. X  if the variable name corresponding to the \s-1ARGLIST\s+1 argument is
  556. X  ``\fBARGV\fP'', then the positional parameters of the calling program
  557. X  will be re-assigned to the contents of the argument list.
  558. X***************
  559. X*** 178,188 ****
  560. X  .nf
  561. X  .RS
  562. X  .ft 4
  563. X! @name=( arg1 , arg2 ,  ... )
  564. X  .ft R
  565. X  .RE
  566. X  .fi
  567. X! .SS ""A Final Note on Argument Lists"
  568. X  .PP
  569. X  The word-lists used by the C shell, the arrays used by the Korn shell, the 
  570. X  Plan 9 shell, \fIawk\fP, \fIperl\fP, and the positional parameters used by
  571. X--- 178,188 ----
  572. X  .nf
  573. X  .RS
  574. X  .ft 4
  575. X! @name=( arg1 , arg2 ,  ... );
  576. X  .ft R
  577. X  .RE
  578. X  .fi
  579. X! .SS "A Final Note on Argument Lists"
  580. X  .PP
  581. X  The word-lists used by the C shell, the arrays used by the Korn shell, the 
  582. X  Plan 9 shell, \fIawk\fP, \fIperl\fP, and the positional parameters used by
  583. X*** doc/shells.inc.OLD    Tue Mar 26 11:32:55 1991
  584. X--- doc/shells.inc    Tue Mar 26 10:31:22 1991
  585. X***************
  586. X*** 18,24 ****
  587. X  shell syntax to use. At present, \fBparseargs\fP only recognizes
  588. X  ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'', ``awk'', and ``perl''
  589. X  as valid command interpreters. \fIAwk\fP output is slightly different from 
  590. X! that of the other shells in that the actual variable setting are not
  591. X  printed but each line of an associative array is printed (the first field
  592. X  is the array index, the second is the value for that index).
  593. X  If no shell is specified, then the Bourne shell (``sh'') will be assumed.
  594. X--- 18,24 ----
  595. X  shell syntax to use. At present, \fBparseargs\fP only recognizes
  596. X  ``sh'', ``csh'', ``ksh'', ``tcsh'', ``bash'', ``rc'', ``awk'', and ``perl''
  597. X  as valid command interpreters. \fIAwk\fP output is slightly different from 
  598. X! that of the other shells in that the actual variable settings are not
  599. X  printed but each line of an associative array is printed (the first field
  600. X  is the array index, the second is the value for that index).
  601. X  If no shell is specified, then the Bourne shell (``sh'') will be assumed.
  602. X*** parseargs.c.OLD    Tue Mar 26 11:33:29 1991
  603. X--- parseargs.c    Tue Mar 26 10:38:26 1991
  604. X***************
  605. X*** 13,19 ****
  606. X  **    arguments, converts values to the desired type, and diagnoses problems
  607. X  **    such as missing arguments, extra arguments, and argument values that
  608. X  **    are syntactically incorrect.  Other behavior such as prompting the
  609. X! **    user for missing arguments and ignoring as command-line syntax may be
  610. X  **    specified on the command-line through the use of various options, or
  611. X  **    through the use of the "PARSECNTL" environment variable.
  612. X  **
  613. X--- 13,19 ----
  614. X  **    arguments, converts values to the desired type, and diagnoses problems
  615. X  **    such as missing arguments, extra arguments, and argument values that
  616. X  **    are syntactically incorrect.  Other behavior such as prompting the
  617. X! **    user for missing arguments and ignoring bad command-line syntax may be
  618. X  **    specified on the command-line through the use of various options, or
  619. X  **    through the use of the "PARSECNTL" environment variable.
  620. X  **
  621. X***************
  622. X*** 158,164 ****
  623. X  **    to use. At present, parseargs only recognizes "sh", "csh", "ksh",
  624. X  **    "tcsh", "bash", "rc", "awk", and "perl" as valid command interpreters.
  625. X  **    Awk output is slightly different from that of the other shells in that
  626. X! **    the actual variable setting are not printed but each line of an
  627. X  **    associative array is printed (the first field is the array index, the
  628. X  **    second is the value for that index).  If no shell is specified, then
  629. X  **    the Bourne shell ("sh") will be assumed.
  630. X--- 158,164 ----
  631. X  **    to use. At present, parseargs only recognizes "sh", "csh", "ksh",
  632. X  **    "tcsh", "bash", "rc", "awk", and "perl" as valid command interpreters.
  633. X  **    Awk output is slightly different from that of the other shells in that
  634. X! **    the actual variable settings are not printed but each line of an
  635. X  **    associative array is printed (the first field is the array index, the
  636. X  **    second is the value for that index).  If no shell is specified, then
  637. X  **    the Bourne shell ("sh") will be assumed.
  638. X***************
  639. X*** 1578,1584 ****
  640. X  **    For perl, each argument list is considered an array and is set using
  641. X  **    the following syntax:
  642. X  **
  643. X! **         @name=( arg1 , arg2 ,  ... )
  644. X  **
  645. X  ** ^A_Final_Note_on_Argument_Lists:
  646. X  **    The word-lists used by the C shell, the arrays used by the Korn shell,
  647. X--- 1578,1584 ----
  648. X  **    For perl, each argument list is considered an array and is set using
  649. X  **    the following syntax:
  650. X  **
  651. X! **         @name=( arg1 , arg2 ,  ... );
  652. X  **
  653. X  ** ^A_Final_Note_on_Argument_Lists:
  654. X  **    The word-lists used by the C shell, the arrays used by the Korn shell,
  655. X*** parseargs.h.OLD    Tue Mar 26 11:33:56 1991
  656. X--- parseargs.h    Tue Mar 26 11:10:05 1991
  657. X***************
  658. X*** 70,76 ****
  659. X  */ 
  660. X     BOOL (*ad_type) ARGS((struct _argdesc *, char *, BOOL));
  661. X  /*    -- This field is a pointer to a type conversion function (such as the
  662. X! **       ones provided in argtype(3). The type conversion function is respon-
  663. X  **       sible for verifying the validity of the argument, allocating any
  664. X  **       necessary storage for its internal representation, and converting
  665. X  **       the command-line argument into its required internal form. The type
  666. X--- 70,76 ----
  667. X  */ 
  668. X     BOOL (*ad_type) ARGS((struct _argdesc *, char *, BOOL));
  669. X  /*    -- This field is a pointer to a type conversion function (such as the
  670. X! **       ones provided in argtype(3)). The type conversion function is respon-
  671. X  **       sible for verifying the validity of the argument, allocating any
  672. X  **       necessary storage for its internal representation, and converting
  673. X  **       the command-line argument into its required internal form. The type
  674. X***************
  675. X*** 89,108 ****
  676. X  **       pointer to a number, a boolean value, a string, a list, or anything
  677. X  **       else for which there exists a corresponding arg-type function to
  678. X  **       use in the ad_type field. In the case of of parseargs(1) this field
  679. X! **       must be the name of the corresponding shell variable which eventually
  680. X! **       hold the value of the argument given on the command-line.
  681. X  */ 
  682. X     CONST char *ad_prompt;
  683. X  /*    -- This field contains the long-name of the argument and an optional
  684. X  **       description (the description must be separated from the long-name by
  685. X! **       at least one whitespace characters and may optionally be enclosed in
  686. X  **       a set of balanced delimiters (such as parentheses, curly-braces,
  687. X! **       square-brackets, or angle-brackets. If the long-name contains any
  688. X  **       uppercase characters, then the substring of long-name consisting of
  689. X! **       all uppercase characters is used as the argument name and the entire
  690. X! **       long-name is used as the name of the argument-value (if a value my be
  691. X! **       supplied). The long-name may be matched by supplying a unique prefix
  692. X! **       of either the argument name or the argument-value name.
  693. X  */ 
  694. X  } ARGDESC;
  695. X  /**^^**********************************************************************/
  696. X--- 89,108 ----
  697. X  **       pointer to a number, a boolean value, a string, a list, or anything
  698. X  **       else for which there exists a corresponding arg-type function to
  699. X  **       use in the ad_type field. In the case of of parseargs(1) this field
  700. X! **       must be the name of the corresponding shell variable which will
  701. X! **       eventually hold the value of the argument given on the command-line.
  702. X  */ 
  703. X     CONST char *ad_prompt;
  704. X  /*    -- This field contains the long-name of the argument and an optional
  705. X  **       description (the description must be separated from the long-name by
  706. X! **       at least one whitespace character and may optionally be enclosed in
  707. X  **       a set of balanced delimiters (such as parentheses, curly-braces,
  708. X! **       square-brackets, or angle-brackets). If the long-name contains any
  709. X  **       uppercase characters, then the substring of long-name consisting of
  710. X! **       all uppercase characters is used as the argument keyword and the
  711. X! **       entire long-name is used as the name of the argument (if a value may
  712. X! **       be supplied). The long-name may be matched by supplying a unique
  713. X! **       prefix of either the argument keyword or the argument name.
  714. X  */ 
  715. X  } ARGDESC;
  716. X  /**^^**********************************************************************/
  717. X***************
  718. X*** 419,433 ****
  719. X  **    ARGLISTNULL is simply the NULL argument-list pointer.  L_NEXT and
  720. X  **    L_STRING each take a pointer to a non-NULL ArgList structure. L_NEXT
  721. X  **    returns the address of the next item in the list and L_STRING returns
  722. X! **    the string-value of the current list-item.  L_FLAGS return the arg-
  723. X! **    flags for a given item in the list. With non-multivalued, only the
  724. X  **    flags in the argument descriptor are needed; lists and vectors however
  725. X  **    need a set of flags for each item they contain. Once an arg-list has
  726. X  **    been created, it may be deallocated using the function listFree. List-
  727. X! **    Free takes two parameters, the first of which is the address of the
  728. X! **    first item in the arg-list, and the second of which is a boolean value
  729. X! **    that is TRUE only if each value pointed to by each item should also be
  730. X! **    deallocated.
  731. X  **
  732. X  **    An alternative to argument-lists is argument vectors (or arg-vectors).
  733. X  **    Arg-vectors use the ARGVEC flag instead of the ARGLIST flag and do not
  734. X--- 419,430 ----
  735. X  **    ARGLISTNULL is simply the NULL argument-list pointer.  L_NEXT and
  736. X  **    L_STRING each take a pointer to a non-NULL ArgList structure. L_NEXT
  737. X  **    returns the address of the next item in the list and L_STRING returns
  738. X! **    the string-value of the current list-item.  L_FLAGS return the argflags
  739. X! **    for a given item in the list. With non-multivalued arguments, only the
  740. X  **    flags in the argument descriptor are needed; lists and vectors however
  741. X  **    need a set of flags for each item they contain. Once an arg-list has
  742. X  **    been created, it may be deallocated using the function listFree. List-
  743. X! **    Free takes one parameter: the address of the first item in the arg-list.
  744. X  **
  745. X  **    An alternative to argument-lists is argument vectors (or arg-vectors).
  746. X  **    Arg-vectors use the ARGVEC flag instead of the ARGLIST flag and do not
  747. X*** test.rc.OLD    Tue Mar 26 11:35:44 1991
  748. X--- test.rc    Mon Mar 25 09:47:08 1991
  749. X***************
  750. X*** 21,34 ****
  751. X  yflag='TRUE'     ## set defaults (dir="."; count=1; sepch=',') ##
  752. X  
  753. X  ## parse command-line and save assignments in a temporary file ##
  754. X! parseargs -s rc -e ARGUMENTS -u -- $^NAME "$@" >/tmp/tmp$$
  755. X  if ( $status != 0 ) {
  756. X!   rm -f /tmp/tmp$$;
  757. X    exit 2  ## non-zero status (usage given)
  758. X  }
  759. X  
  760. X  ## evaluate results from parseargs and remove temporary file
  761. X! . /tmp/tmp$$;  rm -f /tmp/tmp$$
  762. X  
  763. X  ## echo  the parsed arguments (use defaults if not defined)
  764. X  echo 'ARGUMENTS:'
  765. X--- 21,34 ----
  766. X  yflag='TRUE'     ## set defaults (dir="."; count=1; sepch=',') ##
  767. X  
  768. X  ## parse command-line and save assignments in a temporary file ##
  769. X! parseargs -s rc -e ARGUMENTS -u -- $^NAME $@ >/tmp/tmp$pid
  770. X  if ( $status != 0 ) {
  771. X!   rm -f /tmp/tmp$pid;
  772. X    exit 2  ## non-zero status (usage given)
  773. X  }
  774. X  
  775. X  ## evaluate results from parseargs and remove temporary file
  776. X! . /tmp/tmp$pid;  rm -f /tmp/tmp$pid
  777. X  
  778. X  ## echo  the parsed arguments (use defaults if not defined)
  779. X  echo 'ARGUMENTS:'
  780. X*** xparse.c.OLD    Tue Mar 26 11:36:41 1991
  781. X--- xparse.c    Tue Mar 26 11:12:58 1991
  782. X***************
  783. X*** 63,69 ****
  784. X  **    When a non-multivalued argument appears more than once on the
  785. X  **    command-line then only the last value supplied is used. A problem
  786. X  **    occurs however in the following scenario: suppose `-s' is an option
  787. X! **    that takes an optional string argument (nd suppose `-x' is some
  788. X  **    boolean flag). Then if the following command-line is issued:
  789. X  **
  790. X  **         command  -s string  -x  -s
  791. X--- 63,69 ----
  792. X  **    When a non-multivalued argument appears more than once on the
  793. X  **    command-line then only the last value supplied is used. A problem
  794. X  **    occurs however in the following scenario: suppose `-s' is an option
  795. X! **    that takes an optional string argument (and suppose `-x' is some
  796. X  **    boolean flag). Then if the following command-line is issued:
  797. X  **
  798. X  **         command  -s string  -x  -s
  799. X***************
  800. X*** 1143,1149 ****
  801. X  **                       command-line arguments and continue execution of
  802. X  **                       the program. Normally, if an argument is unmatched
  803. X  **                       (or is improperly specified), a usage message is
  804. X! **                       printed program execution is terminated.
  805. X  **
  806. X  **         "OptsOnly"    Under UNIX, setting this flag will disable the
  807. X  **                       parsing of long-option syntax. This will cause all
  808. X--- 1143,1149 ----
  809. X  **                       command-line arguments and continue execution of
  810. X  **                       the program. Normally, if an argument is unmatched
  811. X  **                       (or is improperly specified), a usage message is
  812. X! **                       printed and program execution is terminated.
  813. X  **
  814. X  **         "OptsOnly"    Under UNIX, setting this flag will disable the
  815. X  **                       parsing of long-option syntax. This will cause all
  816. X***************
  817. X*** 1171,1182 ****
  818. X  **                       examples are considered to consist of one option
  819. X  **                       and one positional argument.
  820. X  **
  821. X! **         "CaseIgnore"  Setting this flag cause character-case to be
  822. X  **                       ignored when attempting to match single-character
  823. X  **                       argument names (i.e. causes "-i" and "-I" will be
  824. X  **                       considered equivalent).
  825. X  **
  826. X! **    If the environment variable "PARSECNTL" is empty or undefined, then
  827. X  **    parsing behavior set by the programmer is used.  If the programmer has
  828. X  **    not explicitly used parsecntl(3) to modify the parsing behavior, then
  829. X  **    the default behavior will be "Flags1st" for Unix Systems,
  830. X--- 1171,1182 ----
  831. X  **                       examples are considered to consist of one option
  832. X  **                       and one positional argument.
  833. X  **
  834. X! **         "CaseIgnore"  Setting this flag causes character-case to be
  835. X  **                       ignored when attempting to match single-character
  836. X  **                       argument names (i.e. causes "-i" and "-I" will be
  837. X  **                       considered equivalent).
  838. X  **
  839. X! **    If the environment variable "PARSECNTL" is empty or undefined, then the
  840. X  **    parsing behavior set by the programmer is used.  If the programmer has
  841. X  **    not explicitly used parsecntl(3) to modify the parsing behavior, then
  842. X  **    the default behavior will be "Flags1st" for Unix Systems,
  843. X***************
  844. X*** 1997,2003 ****
  845. X    
  846. X  /* ^DESCRIPTION:
  847. X  **    Given an ArgList and an argdesc array, lparseargs will parse arguments
  848. X! **    in a file in much the same manner as parseargs.
  849. X  **
  850. X  ** ^REQUIREMENTS:
  851. X  **    <argls> should be an ArgList of strings
  852. X--- 1997,2003 ----
  853. X    
  854. X  /* ^DESCRIPTION:
  855. X  **    Given an ArgList and an argdesc array, lparseargs will parse arguments
  856. X! **    in an ArgList in much the same manner as parseargs.
  857. X  **
  858. X  ** ^REQUIREMENTS:
  859. X  **    <argls> should be an ArgList of strings
  860. END_OF_FILE
  861. if test 38200 -ne `wc -c <'PATCH'`; then
  862.     echo shar: \"'PATCH'\" unpacked with wrong size!
  863. fi
  864. # end of 'PATCH'
  865. fi
  866. echo shar: End of shell archive.
  867. exit 0
  868.  
  869. exit 0 # Just in case...
  870. -- 
  871. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  872. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  873. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  874. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  875.